package user_shop

import (
	"goods-rpc/models"
	users "goods-rpc/proto/user"
)

func userModelInfo(user *models.UserShop) (info *users.UserShopInfo, err error) {
	return &users.UserShopInfo{
		Id:       int64(user.ID),
		Username: user.Username,
		Password: user.Password,
		Phone:    user.Phone,
		Address:  user.Address,
		Email:    user.Email,
	}, nil
}

func TakeLoginOne(username string) (*users.UserShopInfo, error) {
	m := new(models.UserShop)
	loginOne, err := m.LoginOne(username)
	if err != nil {
		return nil, nil
	}
	return userModelInfo(loginOne)
}

func TakeLoginTow(phone string) (*users.UserShopInfo, error) {
	m := new(models.UserShop)
	loginTow, err := m.LoginTow(phone)
	if err != nil {
		return nil, nil
	}
	return userModelInfo(loginTow)
}
